package com.cryptooj.project.model.enums;

import org.apache.commons.lang3.ObjectUtils;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 *  判题信息消息
 * */
public enum JudgeInfoMessageEnum {

    ACCEPTED("成功","Accepted"),
    WRONG_ANSWER("错误答案","Wrong Answer"),
    COMPILE_ERROR("编译错误","Compile Error"),
    TIME_LIMIT_EXCEEDED("时间消耗超出异常","Time Limit Exceeded"),
    MEMORY_LIMIT_EXCEEDED("内存消耗超出限制","Memory Limit Exceeded"),
    PRESENTATION_ERROR("展示错误","Presentation Error"),
    WAITING("等待中","Waiting"),
    OUTPUT_LIMIT_EXCEEDED("输出溢出","Output Limit Exceeded"),
    DANGEROUS_OPERATION("高危操作","Dangerous Operation"),
    RUNTIME_ERROR("运行异常","Runtime Error"),
    SYSTEM_ERROR("系统异常","System Error");

    private final String text;

    private final String value;

    JudgeInfoMessageEnum(String text, String value){
        this.text = text;
        this.value = value;
    }

    // 获取值列表（处理values()的返回类型）
    public List<String> getValues() {
        return Arrays.stream(values())
                .map(item->item.value)
                .collect(Collectors.toList());
    }

    // 根据值获取枚举常量
    public static JudgeInfoMessageEnum getEnumByValue(String value){
        if(ObjectUtils.isEmpty(value)){
            return null;
        }
        for(JudgeInfoMessageEnum item : JudgeInfoMessageEnum.values()){
            if(item.getValue().equals(value)){
                return item;
            }
        }
        return null;
    }

    public String getText() {
        return text;
    }
    public String getValue() {
        return value;
    }
}
